Skip to content

Conversation

@donilg
Copy link
Contributor

@donilg donilg commented Jun 29, 2025

There is an example of correct openAPI specification:

{
  "openapi": "3.0.0",
  "info": {
    "title": "Simple API",
    "description": "A simple API with GET and POST endpoints",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://api.example.com/v1"
    }
  ],
  "paths": {
    "/users": {
      "get": {
        "summary": "Method with non-escaped parameter and escaped parameter",
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "description": "Non-escaped parameter that should not be modified",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "type",
            "in": "query",
            "description": "Escaped parameter that should be modified",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "active",
                "inactive",
                "pending"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/User"
                }
              }
            }
          }
        }
      }
    },
    "/users/{type}/{var}/{id}": {
      "get": {
        "summary": "Method with non-escaped parameter, escaped string parameter and escaped long parameter",
        "parameters": [
          {
            "name": "type",
            "in": "path",
            "required": true,
            "description": "Escaped string parameter that should be modified",
            "schema": {
              "type": "string",
              "enum": [
                "active",
                "inactive",
                "pending"
              ]
            }
          },
          {
            "name": "var",
            "in": "path",
            "required": true,
            "description": "Escaped long parameter that should be modified",
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Non-escaped parameter that should not be modified",
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/User"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "User": {
        "type": "object",
        "properties": {
          "result": {
            "type": "string",
            "enum": [
              "active",
              "inactive",
              "pending"
            ]
          }
        },
        "required": [
          "result"
        ]
      }
    }
  }
}

For given OpenAPI specification generated not compiled code because it uses reserved words.
I changed baseName to paramName to use escaped variables instead of reserved words for scala-http4s-server

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
  • File the PR against the correct branch: master (upcoming 7.x.0 minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

Hello! 👋
I'd love to get your eyes on this PR when you have a moment.
Thanks in advance!

@clasnake (2017/07), @shijinkui (2018/01), @ramzimaalej (2018/03), @chameleon82 (2020/03), @Bouillie (2020/04) @Fish86 (2023/06)

@wing328
Copy link
Member

wing328 commented Jul 2, 2025

thanks for the pr

tested locally to confirm the fix works as expected

$ sbt compile
[info] welcome to sbt 1.10.11 (Eclipse Adoptium Java 17.0.10)
[info] loading settings for project global-plugins from gpg.sbt...
[info] loading global plugins from C:\Users\wing3\.sbt\1.0\plugins
[info] loading project definition from C:\Users\wing3\AppData\Local\Temp\ajson\project
[info] loading settings for project ajson from build.sbt...
[info] set current project to ajson (in build file:/C:/Users/wing3/AppData/Local/Temp/ajson/)
[info] Executing in batch mode. For better performance use sbt's shell
[info] compiling 5 Scala sources to C:\Users\wing3\AppData\Local\Temp\ajson\target\scala-2.13\classes ...
[info] done compiling
[success] Total time: 11 s, completed Jul 2, 2025, 3:28:33 PM

@wing328 wing328 merged commit af6ab0e into OpenAPITools:master Jul 2, 2025
14 checks passed
@wing328 wing328 mentioned this pull request Jul 2, 2025
5 tasks
@wing328
Copy link
Member

wing328 commented Jul 2, 2025

FYI. Merged #21507 to add tests covering reserved words moving forward

@wing328 wing328 added this to the 7.15.0 milestone Aug 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants